package com.hkts.reportform.sodata.controller;

import com.hkts.reportform.sodata.serviceImp.SoServiceImp;
import com.hkts.reportform.utils.CustomPage;
import com.hkts.reportform.utils.Result;
import com.hkts.reportform.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/erp/SO")
public class SoController {

    @Autowired
    private SoServiceImp soServiceImp;

    /**
     *  销售情况列表
     * @param dateType
     * @param beginDate
     * @param endDate
     * @return
     * @throws Exception
     */
    @RequestMapping("/salesOrderList")
    public Result<Object> getSalesOrderList(String dateType,String beginDate,String endDate, CustomPage page) {
        CustomPage customPage = soServiceImp.salesOrderList(dateType, beginDate, endDate, page);
        return ResultUtil.data(customPage);
    }
    @RequestMapping("/salesOrderStatistics")
    public Result<Object> getSalesOrderStatistics(String dateType,String beginDate,String endDate) throws ParseException {
        Map<String,  Object> stringMapMap = soServiceImp.salesOrderStatistics(dateType, beginDate, endDate);
        return ResultUtil.data(stringMapMap);
    }
    @RequestMapping("/salesOdSttts")
    public Result<Object> getSalesOdSttts(String dateType,String beginDate,String endDate) {
        List<Map<String, Object>> map = soServiceImp.sOdStttc(dateType, beginDate, endDate);
        return ResultUtil.data(map);
    }
    @RequestMapping("/salesWeighingList")
    public Result<Object> getSalesWeighingList(String dateType,String beginDate,String endDate, CustomPage page) {
        CustomPage customPage = soServiceImp.salesWeighingList(dateType, beginDate, endDate, page);
        return ResultUtil.data(customPage);
    }
    @RequestMapping("/carNumAndTunnageList")
    public Result<Object> getCarNumAndTunnage (){
        Map<String, Object> carNumAndTunnage = soServiceImp.getCarNumAndTunnage();
        return  ResultUtil.data(carNumAndTunnage);
    }
    @RequestMapping("/getOrderCountByDate")
    public Result<Object> getOrderCountByDate(String dateType, String beginDate, String endDate) throws Exception {
        Map<String, Object> stringObjectMap = soServiceImp.getSalesWeighingByData(dateType, beginDate, endDate);
        return ResultUtil.data(stringObjectMap);
    }
}
